package org.patto.main.config;


import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author songchuanfu
 * @qq 18050164315
 * @ClassName Knife4jConfig
 * @addres 1802284273@qq.com
 * @微信: wx-suagcf
 *
 * Swagger2 相关配置
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Knife4jConfig {

    /**
     * 创建api
     * @return
     */
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .apiInfo(apiInfo())
                .select()
                // api接口扫包范围
                .apis(RequestHandlerSelectors.basePackage("org.patto.main.api"))
                .paths(PathSelectors.any())
                .build();

    }

    /**
     * 配置api信息
     *
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .description("系统Api接口文档")
                .contact(new Contact("songchuanfu", "https://www.patto.com", "1802284273@qq.com"))
                .version("v1.1.0")
                .title("API文档")
                .build();
    }

}
